package org.tong.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.tong.beans.Student;
import org.tong.repository.StudentJpa;

import javax.transaction.Transactional;

/**
 * @author
 * @date 2022-11-15 19:34
 */
@Service
@Transactional
public class StudentService {

    @Autowired
    private StudentFinder studentFinder;

    @Autowired
    private StudentJpa studentJpa;

    public void updateAge(Long id) {
        studentJpa.save(new Student(4L, "效率", 13));
        try {
            Student student = studentFinder.getById(id);
            student.setAge(student.getAge() + 1);
        } catch (Exception e) {

        }
        studentJpa.save(new Student(5L, "小刚", 11));
    }
}
